package com.xxxx;

import com.xxxx.config.SpringConfig;
import com.xxxx.dao.BookDao;
import com.xxxx.service.BookService;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Created By ShaoXikai on 2022/7/20
 */
public class TestAppAnno {

    // @Test
    public void testXml() {
        ApplicationContext b = new ClassPathXmlApplicationContext("beans.txt");
        BookDao b1 = b.getBean(BookDao.class);
        BookService b2 = b.getBean(BookService.class);
        b2.m1();
        b1.m1();
    }


    // 纯注解
    @Test
    public void testAnno() {
        ApplicationContext b = new AnnotationConfigApplicationContext(SpringConfig.class);
        BookDao b1 = b.getBean(BookDao.class);
        BookService b2 = b.getBean(BookService.class);
        b2.m1();
        b1.m1();
    }

}
